import { createVNode, render } from "vue";
import PopupConstructor from "./index.vue";

const $popup = function (options) {
    // 创建div
    const container = document.createElement("div");
    container.className = `__default__container__popup__`;
    //创建虚拟节点
    const vm = createVNode(PopupConstructor, options);
    //渲染虚拟节点
    render(vm, container);
    document.body.appendChild(container);
    container.addEventListener('click', () => {
        document.body.removeChild(container)
    })
};

export default {
    //组件注册
    install(app) {
        app.config.globalProperties.$popup = $popup;
    }
};